package gov.child.dao.impl;

import gov.child.dao.AbstractDao;
import gov.child.dao.AdminDao;
import gov.child.entities.po.EAdmin;
import gov.child.entities.po.ECollection;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

/**
 * @author fzh
 * @since 2017/9/16
 */
@Repository("adminDao")
public class AdminDaoImpl extends AbstractDao implements AdminDao {
    @Override
    public EAdmin findByUsernameAndPassword(String username, String password) {
        Session session = currentSession();
        return (EAdmin) session.createQuery("from EAdmin where username = :username and password = :password")
                .setParameter("username", username)
                .setParameter("password", password).getSingleResult();
    }

    @Override
    public void update(EAdmin admin) {
        currentSession().update(admin);

    }

    @Override
    public void delete(EAdmin admin) {
        currentSession().delete(admin);

    }
}
